<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>10-点击明星按钮进行头像切换</title>
	</head>
	<body>
		<button>刘德华</button>
		<button>张学友</button>
		<!-- 默认让图片区域不为空 -->
		<img src="images/ldh.jpg" alt="刘德华">
		
		<script type="text/javascript">
			//元素对象.属性名 = 值
			var ldh = document.querySelectorAll('button')[0];
			var zxy = document.querySelectorAll('button')[1];
			//图片
			var img = document.querySelector('img');
			ldh.onclick = function(){
				// alert(122);
				img.src = 'images/ldh.jpg';
				img.alt = '刘德华';
			}
			
			zxy.onclick = function(){
				// alert(122);
				img.src = 'images/zxy.jpg';
				img.alt = '张学友';
			}
			
		</script>
	</body>
</html>
